package Zoo.View.ZoomanView;

import Zoo.Entity.AnimalEntity;
import Zoo.Handler.DeleteAnimalViewHandler;

import javax.swing.*;
import java.awt.*;

/**
 * 1、DeleteAnimalView用于动物饲养员删除动物
 */
public class DeleteAnimalView extends JDialog {
    JPanel jPanel=new JPanel();

    JLabel idLable =new JLabel("删除的动物id");
    JTextField idTxt=new JTextField();

    JButton deleteBtn =new JButton("删除");

    DeleteAnimalViewHandler deleteAnimalViewHandler;
    public DeleteAnimalView(ZoomenView1 zoomenView1){
        super(zoomenView1,"删除动物信息",true);

        deleteAnimalViewHandler=new DeleteAnimalViewHandler(this,zoomenView1);

        idLable.setPreferredSize(new Dimension(80,30));
        jPanel.add(idLable);
        idTxt.setPreferredSize(new Dimension(200,30));
        jPanel.add(idTxt);


        Container contentPane=getContentPane();
        contentPane.add(jPanel);

        deleteBtn.addActionListener(deleteAnimalViewHandler);
        jPanel.add(deleteBtn);

        setSize(350,500);
        setLocationRelativeTo(null);
        //DISPOSE_ON_CLOSE：只销毁当前的窗体
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setResizable(false);
        setVisible(true);


    }

    //获取修改后的园区对象（但园区id是需要修改对象的园区id）
    public AnimalEntity buildDeletedAnimalEntity() {
        AnimalEntity animalEntity=new AnimalEntity();
        animalEntity.setAnimalId(Integer.valueOf(idTxt.getText()));


        return animalEntity;
    }
}
